import axios from '@/utils/request';

/**
 * 新增采购订单
 */
export async function AddPurorder(params) {
    const res = await axios.post('/Purorder/AddPurorder',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取采购订单查询分页列表
 */
 export async function QueryPurorderByCondition(params) {
    const res = await axios.post('/Purorder/QueryPurorderByCondition',params);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取采购订单查询分页列表
 */
export async function QueryChoosePurorderByCondition(params) {
    const res = await axios.post('/Purorder/QueryChoosePurorderByCondition',params);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据id获取采购订单
 */
 export async function QueryPurorderById(id) {
    const res = await axios.get('/Purorder/QueryPurorderById/'+id);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 作废采购订单
 */
export async function DeletePurorder(id) {
    const res = await axios.post('/Purorder/DeletePurorder?id='+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 更新采购订单
 */
 export async function UpdatePurorder(params) {
    const res = await axios.post('/Purorder/UpdatePurorder',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 采购订单(反结算)
 */
export async function AntiSettlePurorder(id) {
    const res = await axios.post('/Purorder/AntiSettlePurorder?id='+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 过账采购订单
 */
export async function SettlePurorder(params) {
    const res = await axios.post('/Purorder/SettlePurorder',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据id获取采购订单
 */
export async function PrintPurorderById(id) {
    const res = await axios.post('/Purorder/PrintPurorderById?id='+id);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}




